﻿using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace MyEventClient.Event
{
    public class BookTitleChangeEventHandler : IIntegrationEventHandler<BookTitleChangeEvent>
    {
        private readonly ILogger<BookTitleChangeEventHandler> _logger;

        public BookTitleChangeEventHandler(ILogger<BookTitleChangeEventHandler> logger)
        {
            _logger = logger;
        }

        Task IIntegrationEventHandler<BookTitleChangeEvent>.Handle(BookTitleChangeEvent @event)
        {
            _logger.LogInformation("MyLiTestEventHandler begin...");

            //add logistics deal code.
            //........................

            _logger.LogInformation("MyLiTestEvent id:{0},createdate:{1},title:{2},oldtitle:{3}", @event.Id, @event.CreationDate.ToString("yyyy-MM-dd hh:mm:ss"),@event.Title,@event.OldTitle) ;

            _logger.LogInformation("MyLiTestEventHandler End.");

            return Task.CompletedTask;
        }
    }
}
